using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WebControls;
using BusinessLayer;
using InfraStructureLayer;
using EntityLayer;

public partial class News_default : SFPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!Page.IsPostBack)
        //{
        //    if (sfrNews.LoadRepeaterData())
        //    {
        //        return;
        //    }

        //}
    }
    protected bool sfrNews_NeedsDataSource()
    {
        if (this.QueryStringArchive.ToString() == "")
        {
            if (Request.QueryString["Archive"] != null && Request.QueryString["Archive"] != "")
            {
                this.QueryStringArchive = Request.QueryString["Archive"];
            }
        }

        busNews insBusNews = new busNews();
        DataTable insDataTableNews = null;
        if (this.QueryStringArchive == "")
        {
            insDataTableNews = insBusNews.SelectNewsByLanguageId();
        }
        else
        {
            entNews insEntNews = new entNews();
            string archive = new Crypto().DecryptURL(this.QueryStringArchive);
            string year = archive.Substring(0, 4);
            string month = "";
            if (archive.Substring(4, 2).StartsWith("0"))
            {
                month = archive.Substring(5, 1);
            }
            else
            {
                month = archive.Substring(4, 2);
            }
            insEntNews.InsertDate = new DateTime(Convert.ToInt32(year), Convert.ToInt32(month), 1);
            insDataTableNews = insBusNews.SelectNewsByLanguageIdAndYearAndMonth(insEntNews);
        }
        if (insBusNews.HasErrors)
        {
            MessageBoxShow(insBusNews);
            return true;
        }

        sfrNews.SetData(insDataTableNews);
        return insBusNews.HasErrors;
    }
    protected string GenerateUrl(object obj)
    {
        return "~/" + CurrentContext.Language + "/News/" + new Crypto().EncryptURL(obj.ToString()) + ".aspx";
    }
}
